Class FileLocator

Summary

Fully Qualified Name: CodeIgniter\Autoloader\FileLocator

Description

Class FileLocator

Allows loading non-class files in a namespaced manner. Works with Helpers, Views, etc.

Methods

Name Description Defined By
__construct() Constructor FileLocator
findQualifiedNameFromPath() Find the qualified name of a file according to the namespace of the first matched namespace path. FileLocator
getClassname() Examines a file and returns the fully qualified domain name. FileLocator
listFiles() Scans the defined namespaces, returning a list of all files that are contained within the subpath specified by $path. FileLocator
listNamespaceFiles() Scans the provided namespace, returning a list of all files that are contained within the subpath specified by $path. FileLocator
locateFile() Attempts to locate a file by examining the name for a namespace and looking through the PSR-4 namespaced files that we know about. FileLocator
search() Searches through all of the defined namespaces looking for a file. FileLocator

Method Details

__construct()

Constructor

Parameter Name Type Description
$autoloader \Autoloader

Returns:

findQualifiedNameFromPath()

Find the qualified name of a file according to the namespace of the first matched namespace path.

Parameter Name Type Description
$path string

Returns: string|bool The qualified name or false if the path is not found

getClassname()

Examines a file and returns the fully qualified domain name.

Parameter Name Type Description
$file string

Returns: string

listFiles()

Scans the defined namespaces, returning a list of all files that are contained within the subpath specified by $path.

Parameter Name Type Description
$path string

Returns: array

listNamespaceFiles()

Scans the provided namespace, returning a list of all files that are contained within the subpath specified by $path.

Parameter Name Type Description
$prefix string
$path string

Returns: array

locateFile()

Attempts to locate a file by examining the name for a namespace and looking through the PSR-4 namespaced files that we know about.

Parameter Name Type Description
$file string The
$folder string The
$ext string The

Returns: string|bool The path to the file, or false if not found.

search()

Searches through all of the defined namespaces looking for a file.

Returns an array of all found locations for the defined file.

Example:

$locator->search('Config/Routes.php'); // Assuming PSR4 namespaces include foo and bar, might return: [

 'app/Modules/foo/Config/Routes.php',
 'app/Modules/bar/Config/Routes.php',

]

Parameter Name Type Description
$path string
$ext string

Returns: array

Top